package com.example.leetcode.tree;

import com.example.leetcode.tree.common.TreeNode;
import com.example.leetcode.tree.common.TreeUtils;

/**
 * AC
 */
class Solution108 {
    public TreeNode sortedArrayToBST(int[] nums) {
        if (nums == null || nums.length == 0) {
            return new TreeNode();
        }
        return TreeUtils.generateAVLBySortedArray(nums, 0, nums.length - 1);
    }
}

/**
 * 108. 将有序数组转换为二叉搜索树
 */
public class leetcode108 {

    public static void main(String[] args) {

        int[] nums = {-10, -3, 0, 5, 9};

        Solution108 solution108 = new Solution108();

        TreeUtils.treeBFSTraverseWithLevelInfo(solution108.sortedArrayToBST(nums));

    }
}
